package Ooday03;
/**引用类型数组的演示*/
public class RefArrayDemo {
    public static void main(String[] args) {
        //声明Dog型数组dogs，包含三个元素，每个元素都是Dog类型，默认值为null
      // Dog[]dogs = new Dog[3];
       //声明Chick型数组chick，包含三个元素，每个元素都是Chick类型，默认值为null
      // Chick[]chicks= new Chick[3];
        //声明Fish型数组fish，包含两个元素，每个元素都是fish类型，默认值为null
       //Fish[]fish = new Fish[2];

       Dog[]dogs=new Dog[3];
       dogs[0]=new Dog("大黄",2,"黄");
       dogs[1]=new Dog("小黑",1,"黑");
       dogs[2]=new Dog("小白",3,"白");
       for (int i =0;i<dogs.length;i++){
           System.out.println(dogs[i].name);
           dogs[i].eat();
       }

       Chick[]chicks=new Chick[2];
       chicks[0]=new Chick("小花",2,"花");
       chicks[1]=new Chick("小红",3,"红");
       for (int i =0;i<chicks.length;i++){
           System.out.println(chicks[i].name);
           chicks[i].layEggs();
       }

       Fish[]fish=new Fish[4];
       fish[0]=new Fish("小金",2,"金");
       fish[1]=new Fish("大白",3,"白");
       fish[2]=new Fish("小红",4,"红");
       fish[3]=new Fish("小绿",3,"绿");
       for (int i = 0;i< fish.length;i++){
           System.out.println(fish[i].color);
           fish[i].drink();
       }
    }
}
